<?php
    //
    //  Created by Chagan Anton on 29.07.12.
    //  Copyright Chagan Anton 2012. All rights reserved.
    //
/**
 * This is the model class for table "apps".
 *
 * The followings are the available columns in table 'apps':
 * @property integer $id
 * @property string $name
 * @property string $icon_name
 * @property string $api_key
 * @property string $app_key
 * @property string $userIdentifier
 * @property integer $pushback_programm_id
 */
class Apps extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Apps the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'apps';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('name, icon_name, api_key, app_key, userIdentifier, pushback_programm_id', 'required'),
			array('pushback_programm_id', 'numerical', 'integerOnly'=>true),
			array('icon_name', 'length', 'max'=>12),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, name, icon_name, api_key, app_key, userIdentifier, pushback_programm_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'name' => 'Name',
			'icon_name' => 'Icon Name',
			'api_key' => 'Api Key',
			'app_key' => 'App Key',
			'userIdentifier' => 'User Identifier',
			'pushback_programm_id' => 'Pushback Programm',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('icon_name',$this->icon_name,true);
		$criteria->compare('api_key',$this->api_key,true);
		$criteria->compare('app_key',$this->app_key,true);
		$criteria->compare('userIdentifier',$this->userIdentifier,true);
		$criteria->compare('pushback_programm_id',$this->pushback_programm_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}